From 033a80677087b322789d2748e83b764545f76c6b Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Wed, 16 Dec 2020 16:41:46 +0100 Subject: [PATCH] x86: clobber registers in switch_stack_and_jump() when !LIVEPATCH In order to have the same effect on registers as a call to check_for_livepatch_work() may have, clobber all call-clobbered registers in debug builds. Signed-off-by: Jan Beulich Reviewed-by: Wei Liu --- xen/include/asm-x86/current.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xen/include/asm-x86/current.h b/xen/include/asm-x86/current.h index 4d8822f78c..231994a245 100644 --- a/xen/include/asm-x86/current.h +++ b/xen/include/asm-x86/current.h @@ -120,6 +120,14 @@ unsigned long get_stack_dump_bottom (unsigned long sp); #ifdef CONFIG_LIVEPATCH # define CHECK_FOR_LIVEPATCH_WORK "call check_for_livepatch_work;" +#elif defined(CONFIG_DEBUG) +/* Mimic the clobbering effect a call has on registers. */ +# define CHECK_FOR_LIVEPATCH_WORK \ + "mov $0x1234567890abcdef, %%rax\n\t" \ + "mov %%rax, %%rcx; mov %%rax, %%rdx\n\t" \ + "mov %%rax, %%rsi; mov %%rax, %%rdi\n\t" \ + "mov %%rax, %%r8; mov %%rax, %%r9\n\t" \ + "mov %%rax, %%r10; mov %%rax, %%r11\n\t" #else # define CHECK_FOR_LIVEPATCH_WORK "" #endif -- 2.30.2